package com.itheima.stringdemo;

public class stringDemo7 {
    public static void main(String[] args) {
        //定义一个方法，实现字符串反转
        String result = reverse("abc");
        System.out.println(result);
    }

    //实现字符串的反转
    public static String reverse(String str) {
        String result = "";
        for (int i = str.length()-1; i >= 0; i--) {
            char c = str.charAt(i);//倒着获取字符串中的每一个字符
            result+=c;//拼接
        }
        return result;
    }
}
